<?php 
	
	/**
	 * 公用函数库
	 */
	
	/**
	 * UTF 转 GBK
	 * @param $str 
	 */
	function utf2gbk($str){
		if(function_exists('mb_convert_encoding')){
			return mb_convert_encoding($str, 'gbk');
		}else{
			return iconv('utf-8', 'gbk', $str);
		}
	}

	/**
	 * GBK 转 UTF
	 */
	function gbk2utf($str){
		if(function_exists('mb_convert_encoding')){
			return mb_convert_encoding($str, 'utf-8');
		}else{
			return iconv('gbk', 'utf-8', $str);
		}
	}










	/**
	 * 验证方法
	 * @param $regex 表达式
	 * @param $str 
	 * @param $order   
	 */
	function check_reg($regex,$str,$order = 0){
		$status = "";
		if(preg_match($regex,$str)){
			$status = 'passed type!';
		}else{
			$status = 'wrong type!';
		}
		echo $order.' **************** gorgeous split line ****************'.PHP_EOL;
		echo 'specification : { '.$regex .' }'.PHP_EOL;
		echo 'data : '  . $str .PHP_EOL;
		echo 'status : '.$status.PHP_EOL;
	}






?>